forked from solana-labs/solana
-
Notifications
You must be signed in to change notification settings - Fork 341
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Skip slot fix #4843
Merged
Merged
Skip slot fix #4843
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jstarry
previously approved these changes
Feb 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice find!
poh/src/poh_recorder.rs
Outdated
// previous leader's slots. | ||
// If so, PoH is currently building on the previous leader's blocks | ||
// If not, PoH is building on a different fork | ||
slot == self.start_slot() | ||
}) | ||
} | ||
|
||
// Check if the last slot PoH reset onto was the previous leader's last slot. | ||
fn building_off_previous_leader_last_block(&self, my_pubkey: &Pubkey, next_slot: Slot) -> bool { | ||
// Walk backwards from the next slot we want to build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should be "from the slot before our next leader slot"
jstarry
approved these changes
Feb 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
We see a case where we skip 1 more slot than we have to after a partitioning scenario.
Sequence goes like this:
Step 7 is the bug. We could build N+5 after Leader A is done with all of its blocks, but we don't.
Also note a few additional key points to help understand why this is broken:
fn next_leader_slot
also checks for existence of slots in blockstore to identify which slot to start on. In the example above, when resetting onto N+3, we will set our next leader slot range to be N+5 to N+7.leader_first_tick_height_including_grace_ticks
)fn reached_leader_tick
(see https://github.com/anza-xyz/agave/blob/master/poh/src/poh_recorder.rs#L499-L504)that lets us skip grace ticks because we detect PoH was reset to run immediately. But this conditional is broken when we skip our first leader slot.Summary of Changes
fn can_skip_grace_ticks
to handle this specific case. Essentially, if we see we're building off the previous leader's blocks, allow skipping grace ticks if we've reset onto their last block.fn reached_leader_tick
, including the newly added pathTesting
The first commit in this PR includes some debug prints that were used to confirm every path is covered by unit test:
When running the updated unit test against unfixed
fn can_skip_grace_ticks
, we can see it fails for the case where we expect to be able to skip grace ticks when building off the previous leader's last block